package com.hs.biye.controller.user;

import com.hs.biye.constant.MessageConstant;
import com.hs.biye.excepction.BaseException;
import com.hs.biye.model.DTO.PatientRequest;
import com.hs.biye.model.VO.*;
import com.hs.biye.model.reslut.Result;
import com.hs.biye.model.reslut.ResultPage;
import com.hs.biye.service.*;
import com.hs.biye.service.impl.RegnusServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/user/pat")
@Slf4j
public class Patient2Controller {

    @Resource
    private PatientService patientService;


    @Resource
    private RegistrationService registrationService;


    @Resource
    private RegnusService regnusService;


    @Resource
    private DepartmentService departmentService;

    @Resource
    private EmployeeService employeeService;

    @PostMapping("/one")
    public Result<PatientVo> GetAndQuery(@RequestBody PatientRequest patientRequest){
        PatientVo patientVo = patientService.addPatient(patientRequest);
        return Result.success(patientVo);
    }


    //获取科室的id和名称
    @GetMapping("/getNameId")
    public Result<List<DepartmentVo>> getDepartmentNameAndId(@RequestParam String name){
        List<DepartmentVo> departmentNameAndId = departmentService.getDepartmentNameAndId(name);
        return Result.success(departmentNameAndId);
    }



    //根据科室的id获取医生
    @GetMapping("/getdoctor")
    public Result<List<RegnusVo>> getDoctorNameAndId(@RequestParam("id") Integer id, @RequestParam("date") String date){
        List<RegnusVo> regdoctors = regnusService.regdoctors(id,date);
        return Result.success(regdoctors);
    }



    //历史挂号记录
    @GetMapping("/reglist/{id}")
    public Result<List<RegistrationVo>> regList(@PathVariable Integer id){
        List<RegistrationVo> registrationVos = registrationService.regList(id);
        return Result.success(registrationVos);
    }




    //确定挂号
    @GetMapping("/reg")
    public Result<Boolean> reg(@RequestParam("id") Integer id,@RequestParam("sign") Integer sign
            ,@RequestParam("patientId") Integer patientId){
        Boolean res = regnusService.guahao(id, sign, patientId);
        return Result.success(res);
    }
}
